package edu.ustb.mis.dm.util;

public class NullHandlerUtils {
	public static String DoubleToString(final Double value) {
		if (value == null) {
			return "0";
		}
		return value.toString();
	}

	public static Double NullToDouble(final Object str) {
		if ( (str == null) || str.equals("")) {
			return Double.valueOf(0);
		}
		return Double.parseDouble(str.toString());
	}

	public static float NullToFloat(final Object str) {
		if ( (str == null) || str.equals("")) {
			return Float.valueOf(0);
		}
		return Float.parseFloat(str.toString());
	}

	public static Integer NullToIneger(final Object str) {
		if ( (str == null) || str.equals("")) {
			return Integer.valueOf(0);
		}
		return (Integer)str;
	}

	public static int NullToInt(final Object str) {
		if ( (str == null) || str.equals("")) {
			return Integer.valueOf(0);
		}
		return Integer.parseInt(str.toString());
	}

	public static Long NullToLong(final Object str) {
		if ( (str == null) || str.equals("")) {
			return Long.valueOf(0);
		}
		return Long.parseLong(str.toString());
	}

	public static String NullToString(final Object str) {
		if (str == null) {
			return "";
		}
		return str.toString().trim();
	}
}
